package com.hymall.service.admin;

import com.hymall.bean.vo.AdminConfigExpressVO;
import com.hymall.bean.vo.AdminConfigMallVO;
import com.hymall.bean.vo.AdminConfigOrderVO;
import com.hymall.bean.vo.AdminConfigWxVO;
import com.hymall.mapper.AdminConfigMapper;
import com.hymall.mapper.MarketSystemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: 章鹏
 * @description 配置管理
 * @date: 2022/7/16 14:05
 */
@Service
public class AdminConfigServiceImpl implements AdminConfigService {

    @Autowired
    AdminConfigMapper adminConfigMapper;

    @Autowired
    MarketSystemMapper marketSystemMapper;


    /**
     * @author 章鹏
     * @description 从market_system表中查询商场配置并回显
     * @date 2022/7/16 16:13
     * @param []
     * @return com.hymall.bean.vo.AdminConfigMallVO
     */
    @Override
    public AdminConfigMallVO queryMallConfig() {
        AdminConfigMallVO adminConfigMallVO = new AdminConfigMallVO();
        adminConfigMallVO.setMarket_mall_longitude(adminConfigMapper.queryMarketMallLongitude());
        adminConfigMallVO.setMarket_mall_latitude(adminConfigMapper.queryMarketMallLatitude());
        adminConfigMallVO.setMarket_mall_address(adminConfigMapper.queryMarketMallAddress());
        adminConfigMallVO.setMarket_mall_qq(adminConfigMapper.queryMarketMallQQ());
        adminConfigMallVO.setMarket_mall_phone(adminConfigMapper.queryMarketMallPhone());
        adminConfigMallVO.setMarket_mall_name(adminConfigMapper.queryMarketMallName());
        return adminConfigMallVO;
    }

    /**
     * @author 章鹏
     * @description 修改market_system表中商场配置信息
     * @date 2022/7/16 21:25
     * @param [adminConfigMallVO]
     * @return void
     */
    @Override
    public void updateMallConfig(AdminConfigMallVO adminConfigMallVO) {
        adminConfigMapper.updateMarketMallAddress(adminConfigMallVO.getMarket_mall_address());
        adminConfigMapper.updateMarketMallLatitude(adminConfigMallVO.getMarket_mall_latitude());
        adminConfigMapper.updateMarketMallLongitude(adminConfigMallVO.getMarket_mall_longitude());
        adminConfigMapper.updateMarketMallName(adminConfigMallVO.getMarket_mall_name());
        adminConfigMapper.updateMarketMallPhone(adminConfigMallVO.getMarket_mall_phone());
        adminConfigMapper.updateMarketMallQQ(adminConfigMallVO.getMarket_mall_qq());
    }

    /**
     * @author 章鹏
     * @description 从market_system表中查询运费配置信息并回显
     * @date 2022/7/16 23:08
     * @param []
     * @return com.hymall.bean.vo.AdminConfigExpressVO
     */
    @Override
    public AdminConfigExpressVO queryExpressConfig() {
        AdminConfigExpressVO adminConfigExpressVO = new AdminConfigExpressVO();
        adminConfigExpressVO.setMarket_express_freight_min(adminConfigMapper.queryMarketExpressFreightMin());
        adminConfigExpressVO.setMarket_express_freight_value(adminConfigMapper.queryMarketExpressFreightValue());
        return adminConfigExpressVO;
    }

    /**
     * @author 章鹏
     * @description 修改market_system表中运费配置信息
     * @date 2022/7/16 23:08
     * @param [adminConfigExpressVO]
     * @return void
     */
    @Override
    public void updateMarketExpressConfig(AdminConfigExpressVO adminConfigExpressVO) {
        adminConfigMapper.updateExpressFreightMin(adminConfigExpressVO.getMarket_express_freight_min());
        adminConfigMapper.updateExpressFreightValue(adminConfigExpressVO.getMarket_express_freight_value());
    }

    /**
     * @author 章鹏
     * @description 从market_system表中查询订单管理的配置并回显
     * @date 2022/7/16 23:31
     * @param []
     * @return com.hymall.bean.vo.AdminConfigOrderVO
     */
    @Override
    public AdminConfigOrderVO queryOrderConfig() {
        AdminConfigOrderVO adminConfigOrderVO = new AdminConfigOrderVO();
        adminConfigOrderVO.setMarket_order_comment(adminConfigMapper.queryMarketOrderComment());
        adminConfigOrderVO.setMarket_order_unconfirm(adminConfigMapper.queryMarketOrderUnconfirm());
        adminConfigOrderVO.setMarket_order_unpaid(adminConfigMapper.queryMarketOrderUnpaid());
        return adminConfigOrderVO;
    }

    /**
     * @author 章鹏
     * @description 修改market_system表中修改订单配置信息
     * @date 2022/7/16 23:32
     * @param [adminConfigOrderVO]
     * @return void
     */
    @Override
    public void updateMarketOrderConfig(AdminConfigOrderVO adminConfigOrderVO) {
        adminConfigMapper.updateOrderComment(adminConfigOrderVO.getMarket_order_comment());
        adminConfigMapper.updateOrderUnconfirm(adminConfigOrderVO.getMarket_order_unconfirm());
        adminConfigMapper.updateOrderUnpaid(adminConfigOrderVO.getMarket_order_unpaid());
    }

    /**
     * @author 章鹏
     * @description 从market_system表中查询小程序的配置并回显
     * @date 2022/7/16 23:32
     * @param []
     * @return com.hymall.bean.vo.AdminConfigWxVO
     */
    @Override
    public AdminConfigWxVO queryWxConfig() {
        AdminConfigWxVO adminConfigWxVO = new AdminConfigWxVO();
        adminConfigWxVO.setMarket_wx_catlog_goods(adminConfigMapper.queryMarketWxGoods());
        adminConfigWxVO.setMarket_wx_catlog_list(adminConfigMapper.queryMarketWxList());
        adminConfigWxVO.setMarket_wx_index_brand(adminConfigMapper.queryMarketWxBrand());
        adminConfigWxVO.setMarket_wx_index_hot(adminConfigMapper.queryMarketWxHot());
        adminConfigWxVO.setMarket_wx_index_new(adminConfigMapper.queryMarketWxNew());
        adminConfigWxVO.setMarket_wx_share(adminConfigMapper.queryMarketWxShare());
        adminConfigWxVO.setMarket_wx_index_topic(adminConfigMapper.queryMarketWxTopic());
        return adminConfigWxVO;
    }

    /**
     * @author 章鹏
     * @description 修改market_system表中修改小程序配置信息
     * @date 2022/7/16 23:32
     * @param [adminConfigWxVO]
     * @return void
     */
    @Override
    public void updateMarketWxConfig(AdminConfigWxVO adminConfigWxVO) {
        adminConfigMapper.updateMarketWxBrand(adminConfigWxVO.getMarket_wx_index_brand());
        adminConfigMapper.updateMarketWxList(adminConfigWxVO.getMarket_wx_catlog_list());
        adminConfigMapper.updateMarketWxGoods(adminConfigWxVO.getMarket_wx_catlog_goods());
        adminConfigMapper.updateMarketWxHot(adminConfigWxVO.getMarket_wx_index_hot());
        adminConfigMapper.updateMarketWxShare(adminConfigWxVO.getMarket_wx_share());
        adminConfigMapper.updateMarketWxNew(adminConfigWxVO.getMarket_wx_index_new());
        adminConfigMapper.updateMarketWxTopic(adminConfigWxVO.getMarket_wx_index_topic());
    }
}
